package com.qianyu.project.web.controller.sy;

import com.qianyu.project.service.IComplementSettlementService;
import com.qianyu.project.utils.Result;
import com.qianyu.project.utils.ResultTool;
import com.qianyu.project.vo.ComplementSettlementExtend;
import com.qianyu.project.vo.ProgressPaymentExtend;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("complementSettlement")
public class ComplementSettlementController {
    @Autowired
    private IComplementSettlementService complementSettlementService;

    @GetMapping("getMaxId")
    public Result getMaxId(){
        return ResultTool.success(Long.parseLong(complementSettlementService.getMaxId()) + 1);
    }

    @PostMapping
    public Result save(@RequestBody ComplementSettlementExtend complementSettlementExtend){
        complementSettlementService.saveBoth(complementSettlementExtend.getSettleForm(), complementSettlementExtend.getSettleDetails());
        return ResultTool.success();
    }

    @GetMapping
    public Result getList(@RequestParam Map<String, String> params){
        return ResultTool.success(complementSettlementService.getList(params));
    }

    @GetMapping("{id}")
    public Result selectOne(@PathVariable String id){
        return ResultTool.success(complementSettlementService.selectOne(id));
    }
}
